home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Software Contest 3
/
FM Towns Software Contest 3.iso
/
exp
/
video_t
/
no1
/
c_sorse
/
cdplay2.c
< prev
next >
Wrap
Text File
|
1994-01-07
|
7KB
|
310 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cdrfrb.h>
#include <winb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
int Dialog_cdplay = -1 ;
int Message_cd3 = -1 ;
int Message_cd2 = -1 ;
int Message_cd1 = -1 ;
int TIcon_cd1 = -1 ;
int TIcon_cd2 = -1 ;
int _001Message_cd2 = -1 ;
int _002Message_cd2 = -1 ;
int _003Message_cd2 = -1 ;
int _004Message_cd2 = -1 ;
int _005Message_cd2 = -1 ;
int _006Message_cd2 = -1 ;
int NumBox_cd1 = -1 ;
int _001NumBox_00a7 = -1 ;
int _002NumBox_00a7 = -1 ;
int DButton_cd0 = -1 ;
int Button_cd1 = -1 ;
int DButton_cd2 = -1 ;
int DButton_cd3 = -1 ;
int _007Message_cd2 = -1 ;
int _008Message_cd2 = -1 ;
int _009Message_cd2 = -1 ;
int _010Message_cd2 = -1 ;
int Message_cd10 = -1 ;
int _001Message_cd10 = -1 ;
extern int backid ;
extern int Dia_edit ;
extern int Dialog_menu ;
extern int Text ;
int type=0,strt=0,endt=0;
int sts=0,no=0,acv=0;
struct TIMEADRS st,ed;
struct TIMEADRS *track=NULL;
int CD_open(void)
{
int i;
struct TIMEADRS disc;
if ( track != NULL && acv != 0 )
return 0;
if ( track == NULL && (track =(struct TIMEADRS *)malloc(sizeof(track)*99)) == NULL )
return 1;
do {
i = cdr_cdinfo(0,&type,&strt,&endt,track,&disc);
} while ( i == CDERR7 );
if ( disc.frame-- <= 0 ) {
disc.frame = 74;
if ( disc.sec-- <= 0 ) {
disc.sec = 59;
if ( disc.min-- <= 0 )
return 1;
}
}
track[endt].min = disc.min;
track[endt].sec = disc.sec;
track[endt].frame = disc.frame;
if ( i == 0 ) acv = 1;
return i;
}
void CD_play(cdno,tmin,tsec)
int cdno;
int tmin;
int tsec;
{
int min_dummy;
int sec_dummy;
if(cdno==0) cdr_mstop(0);
if ( cdr_mphase(0,&sts,&no,&st,&ed) != 0 )
return;
if ( sts != 0 )
return;
if ( CD_open() != 0 ) return;
if ( endt > 0 )
{
min_dummy=track[cdno-1].min;
sec_dummy=track[cdno-1].sec;
track[cdno-1].min=track[cdno-1].min+tmin;
track[cdno-1].sec=track[cdno-1].sec+tsec;
if(track[cdno-1].sec >= 60)
{
track[cdno-1].min=track[cdno-1].min+1;
track[cdno-1].sec=track[cdno-1].sec-60;
}
no = cdr_mtplay(0,&(track[cdno-1]),&(track[cdno] ));
track[cdno-1].min=min_dummy;
track[cdno-1].sec=sec_dummy;
}
}
void CD_play2()
{
int i;
if ( cdr_mphase(0,&sts,&no,&st,&ed) != 0 )
return;
if ( sts != 0 )
return;
if ( CD_open() != 0 ) return;
if ( endt > 0 ) {
for ( i=0 ; i < endt && (track[i].min & 0x80) != 0 ; i++ );
no = cdr_mtplay(0,&(track[i]),&(track[endt]));
}
}
int radiocd;
/* initDataCDPLAY:TIcon_cd1:MJ_TICONL40の呼び出し関数 */
/* initDataCDPLAY:TIcon_cd2:MJ_TICONL40の呼び出し関数 */
int cd_bottan(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
/* 現在選択状態にあるボタンを非選択状態にし、選択可にします */
MTL_resetFlagObj(radiocd,~(MS_UNSELECT | MS_TOGGLE)) ;
MMI_SendMessage(radiocd, MM_SHOW, 0) ;
/* 画面選択フラグを更新します */
radiocd = kobj ;
/* 呼び出し元トグルボタンを選択状態にし、選択不可にします */
MTL_setFlagObj(kobj, MS_UNSELECT | MS_TOGGLE) ;
MMI_SendMessage(kobj, MM_SHOW, 0) ;
if (TIcon_cd1 == radiocd)
{
MMI_SendMessage(NumBox_cd1, MM_SETNUMBOX, 5, 0, 0, 0, 1, 0) ;
MMI_SendMessage(_001NumBox_00a7, MM_SETNUMBOX, 5, 0, 0, 0, 1, 0) ;
MMI_SendMessage(_002NumBox_00a7, MM_SETNUMBOX, 5, 0, 0, 0, 1, 0) ;
MMI_SendMessage(NumBox_cd1, MM_SHOW, 0) ;
MMI_SendMessage(_001NumBox_00a7, MM_SHOW, 0) ;
MMI_SendMessage(_002NumBox_00a7, MM_SHOW, 0) ;
}
else {
MMI_SendMessage(NumBox_cd1, MM_SETNUMBOX, 5, 0, 0, 99, 1, 0) ;
MMI_SendMessage(_001NumBox_00a7, MM_SETNUMBOX, 5, 0, 0, 90, 1, 0) ;
MMI_SendMessage(_002NumBox_00a7, MM_SETNUMBOX, 5, 0, 0, 59, 1, 0) ;
MMI_SendMessage(NumBox_cd1, MM_SHOW, 0) ;
MMI_SendMessage(_001NumBox_00a7, MM_SHOW, 0) ;
MMI_SendMessage(_002NumBox_00a7, MM_SHOW, 0) ;
}
return NOERR ;
}
/* initDataCDPLAY:DButton_cd0:MJ_DBUTTONL40の呼び出し関数 */
int cd_stop(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
CD_play(0,0,0);
return NOERR ;
}
/* initDataCDPLAY:Button_cd1:MJ_DBUTTONL40の呼び出し関数 */
int cd_on(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
char moji[250];
int track,mine,sec;
char suu[10];
int min, max, delta, ptColum ;
/* メニューを選択可とします。 */
MMI_SendMessage(NumBox_cd1, MM_GETNUMBOX, 5,
&track, &min, &max, &delta, &ptColum) ;
MMI_SendMessage(_001NumBox_00a7, MM_GETNUMBOX, 5,
&mine, &min, &max, &delta, &ptColum) ;
MMI_SendMessage(_002NumBox_00a7, MM_GETNUMBOX, 5,
&sec, &min, &max, &delta, &ptColum) ;
MTL_resetAtrObj(backid, ~MS_DSPONLYL40) ;
MTL_resetAtrObj(Dialog_menu, ~MS_DSPONLYL40) ;
MTL_resetAtrObj(Dia_edit, ~MS_DSPONLYL40) ;
if (TIcon_cd1 == radiocd)
{
moji[0]='\0';
strcat(moji,"/cdplay");
}
else {
if(track==0)
{
moji[0]='\0';
strcat(moji,"/CDPLAY 0");
}
else {
moji[0]='\0';
strcat(moji,"/CDPLAY ");
_itoa(track,suu,10);
strcat(moji,suu);
strcat(moji," ");
_itoa(mine,suu,10);
strcat(moji,suu);
strcat(moji," ");
_itoa(sec,suu,10);
strcat(moji,suu);
}
}
MMI_SendMessage(Text,MM_SETTEXT,3,moji,200,TRUE) ;
MMI_SendMessage(Text,MM_SETTEXT,3,"\n",5,TRUE) ;
MMI_SendMessage(Dialog_cdplay,MM_ERASE,0) ;
MMI_SendMessage(Dialog_cdplay,MM_DETACH,0) ;
MMI_SendMessage(Text, MM_ERASE, 0) ;
MMI_SendMessage(Text, MM_WAKE, 0) ;
MMI_SendMessage(Text, MM_SHOW, 0) ;
return NOERR ;
}
/* initDataCDPLAY:DButton_cd2:MJ_DBUTTONL40の呼び出し関数 */
int cd_kaku(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
int ret;
int track,mine,sec;
int min, max, delta, ptColum ;
ret=MTL_checkFlagObj(TIcon_cd1,MS_TOGGLE);
if(ret==0x10)
{
CD_play2();
return NOERR ;
}
MMI_SendMessage(NumBox_cd1, MM_GETNUMBOX, 5,
&track, &min, &max, &delta, &ptColum) ;
MMI_SendMessage(_001NumBox_00a7, MM_GETNUMBOX, 5,
&mine, &min, &max, &delta, &ptColum) ;
MMI_SendMessage(_002NumBox_00a7, MM_GETNUMBOX, 5,
&sec, &min, &max, &delta, &ptColum) ;
CD_play(track,mine,sec);
return NOERR ;
}
/* initDataCDPLAY:DButton_cd3:MJ_DBUTTONL40の呼び出し関数 */
int cd_off(kobj, messId, argc, pev, trigger)
int kobj ;
int messId ;
int argc ;
EVENT *pev ;
int trigger ;
{
MMI_SendMessage(Dialog_cdplay,MM_ERASE,0) ;
MMI_SendMessage(Dialog_cdplay,MM_DETACH,0) ;
/* メニューを選択可とします。 */
MTL_resetAtrObj(Dialog_menu, ~MS_DSPONLYL40) ;
MTL_resetAtrObj(Dia_edit, ~MS_DSPONLYL40) ;
MTL_resetAtrObj(backid, ~MS_DSPONLYL40) ;
return NOERR ;
}
int l_cdplay()
{
/* 背景を選択不可とします。*/
MTL_setAtrObj(backid, MS_DSPONLYL40) ;
MTL_setAtrObj(Dialog_menu, MS_DSPONLYL40) ;
MTL_setAtrObj(Dia_edit, MS_DSPONLYL40) ;
MMI_SendMessage(Dialog_cdplay,MM_ATTACH,1,MMI_GetBaseObj()) ;
MMI_SendMessage(Dialog_cdplay, MM_SHOW, 0) ;
return NOERR ;
}